<%-- 
    Document   : obra
    Created on : Jun 24, 2011, 10:51:17 PM
    Author     : esaheki
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="br.unesp.demac.bcc.soo.clarus.bean.Obra" %>
<%@page import="br.unesp.demac.bcc.soo.clarus.bean.Emprestimo" %>
<%@page import="br.unesp.demac.bcc.soo.clarus.util.DateUtil"%>
<jsp:useBean id="obra" scope="session" class="br.unesp.demac.bcc.soo.clarus.bean.Obra" />

<!-- Header -->
<c:import url="/include/header.jsp">
    <c:param name="title" value="Clarus - Renovar" />
</c:import>
<!-- Header -->
<%
if (session.getAttribute("aluno") == null || session.getAttribute("aluno").equals("")) {
    response.sendRedirect("index.jsp");
}
%>

<div class="colmask leftmenu"><div class="colright"><div class="col2">

    <!-- Menu -->
    <c:import url="/menu.jsp" />
    <!-- Menu -->

    </div><div class="col1wrap"><div class="col1">

    <!-- Content -->

    <h2>Obra</h2>

    <table class="tdObra">
        <tr>
            <td class="cover" rowspan="3" width="150"><img src="<%=obra.getCoverUrl()%>" alt="" width="150"/></td>       
            <td class="nomeObra" height="50"><%=obra.getNomeObra()%></td>
        </tr>
        <tr>
            <td class="nomeAutor"><%=obra.autoresToString()%></td>
        </tr>
        <tr>
            <td>
                <table class="tdObraE">
                    <tr>
                        <td class="label" width="80">Localização</td>
                        <td class="value"><%=obra.getLocalizacao().toString()%></td>
                        <td class="label" width="90">Editora</td>
                        <td class="value"><%=obra.getEditora().getNomeEditora()%></td>
                    </tr>
                    <tr>
                        <td class="label" width="80">Ano Publicação</td>
                        <td class="value"><%=obra.getAnoPublicacao()%></td>
                        <td class="label" width="90">Data de Inclusão</td>
                        <td class="value"><%=DateUtil.formatDMY(obra.getDataInclusao())%></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    
    <h2>Últimos Emprestimos</h2>
    <table class="tdResult">
    <tr class="tdheader">
        <td class="tdRetirada" width="140" align="center">Data Retirada</td>
        <td class="tdDevolucao" width="140" align="center">Data Devolução</td>
        <td class="tdNome">Aluno</td>
    </tr>
    
    <%
        int i = 0;
        for (Emprestimo emp : obra.getEmprestimo()) {
            String style = (i % 2 == 0) ? "even" : "odd";
            
            String dataDev = "A Devolver";
            
            if (emp.getDataDevolucao() != null) {
                dataDev = DateUtil.formatDMY(emp.getDataDevolucao());
            }
    %>
    <tr class="<%=style%>">
        <td class="tdRetirada" align="center"><%=DateUtil.formatDMY(emp.getDataEmprestimo())%></td>
        <td class="tdDevolucao" align="center"><%=dataDev%></td>
        <td class="tdNome"><%=emp.getAluno().getNome()%></td>
    </tr>
    <%
        i++;
        }
    %>
    </table>


    <!-- Content -->

</div></div></div></div>

<!-- Footer -->
<c:import url="/include/footer.jsp" />
<!-- Footer -->
